<template>
  <ul>
    <li v-for="item in infoarr1" :key="item.id">
      <span :class="{ completed: item.zt, 'text-decoration-line-through': item.zt }"
        >任务名称:{{ item.renwu }}----{{ item.zt === false ? '未完成' : '已完成' }}</span
      >
      <button @click="toggleTask(item)">切换状态</button>
    </li>
  </ul>
</template>

<script setup lang="ts">
import { type Ins } from '../StuDemo2.vue'
defineProps<{
  infoarr1: Ins[]
}>()
const emit = defineEmits<{
  (e: 'tog', item: Ins): void
}>()

const toggleTask = (item: Ins) => {
  emit('tog', item)
}
</script>

<style lang="scss" scoped>
ul {
  list-style-type: none;
  padding: 0;
}

li {
  margin: 10px 0;
  padding: 5px;
  display: flex;
  justify-content: space-between;
}

.completed {
  color: green;
  text-decoration: line-through;
}
button {
  background-color: #007bff;
  color: white;
  border: none;
  padding: 5px 10px;
  cursor: pointer;
  border-radius: 4px;
}

button:hover {
  background-color: #0056b3;
}
</style>
